package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.RecordFile;
import com.ruoyi.business.service.IRecordFileService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 录制文件Controller
 * 
 * @author asher
 * @date 2021-12-20
 */
@RestController
@RequestMapping("/business/record_file")
public class RecordFileController extends BaseController
{
    @Autowired
    private IRecordFileService recordFileService;

    /**
     * 查询录制文件列表
     */
    @PreAuthorize("@ss.hasPermi('business:record_file:list')")
    @GetMapping("/list")
    public TableDataInfo list(RecordFile recordFile)
    {
        startPage();
        List<RecordFile> list = recordFileService.selectRecordFileList(recordFile);
        return getDataTable(list);
    }

    /**
     * 导出录制文件列表
     */
    @PreAuthorize("@ss.hasPermi('business:record_file:export')")
    @Log(title = "录制文件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RecordFile recordFile)
    {
        List<RecordFile> list = recordFileService.selectRecordFileList(recordFile);
        ExcelUtil<RecordFile> util = new ExcelUtil<RecordFile>(RecordFile.class);
        return util.exportExcel(list, "录制文件数据");
    }

    /**
     * 获取录制文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:record_file:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(recordFileService.selectRecordFileById(id));
    }

    /**
     * 新增录制文件
     */
    @PreAuthorize("@ss.hasPermi('business:record_file:add')")
    @Log(title = "录制文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecordFile recordFile)
    {
        return toAjax(recordFileService.insertRecordFile(recordFile));
    }

    /**
     * 修改录制文件
     */
    @PreAuthorize("@ss.hasPermi('business:record_file:edit')")
    @Log(title = "录制文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RecordFile recordFile)
    {
        return toAjax(recordFileService.updateRecordFile(recordFile));
    }

    /**
     * 删除录制文件
     */
    @PreAuthorize("@ss.hasPermi('business:record_file:remove')")
    @Log(title = "录制文件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(recordFileService.deleteRecordFileByIds(ids));
    }
}
